/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TreePanel.java
 *
 * Created on 21.08.2010, 23:19:39
 */
package model.tree.gui;

import java.awt.image.FilteredImageSource;
import java.awt.image.ReplicateScaleFilter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;


import manager.AnalysManager;
import model.model.Executor;
import model.model.ManageTask;
import model.model.SpecQualify;
import model.model.Task;
import model.tree.ManagerInitTree;
import model.tree.Options;
import model.tree.dnd.CanvasDragSource;
import model.tree.gui.gradient.RoundGradientPaint;

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import model.util.Helper;

/**
 * @author Евгений
 */
public class TreePanel extends javax.swing.JPanel {

    MyTree myTree;

    /**
     * Creates new form TreePanel
     */

    public TreePanel(MyTree myTree) {
        initComponents();
        bOpenLPanel.setVisible(false);
        this.myTree = myTree;
        jSplitPane1.setResizeWeight(1);
        treePanel.add(new JScrollPane(myTree));
        new CanvasDragSource(bCoordinator, bManager, bIngener);
        makeButton();
        bCoordinator.setVisible(false);
        jLabel2.setVisible(false);

        jTable1.getColumnModel().getColumn(0).setMinWidth(0);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(0);
        jTable3.getColumnModel().getColumn(0).setMinWidth(0);
        jTable3.getColumnModel().getColumn(0).setMaxWidth(0);


        jTable1.setDefaultRenderer(Object.class, new TaskRenderer());
        jTable3.setDefaultRenderer(Object.class, new TaskRenderer());


    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        buttonGroup = new javax.swing.ButtonGroup();
        panelLeft = new javax.swing.JPanel();
        bMakeTree = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        bCoordinator = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        bManager = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        bIngener = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        bMakeTasksByTree = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel5 = new javax.swing.JPanel();
        bOpenLPanel = new javax.swing.JButton();
        bCloseLPanel = new javax.swing.JButton();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane4 = new javax.swing.JScrollPane();
        pRight = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        lName = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        lTime = new javax.swing.JLabel();
        bFixTask = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel8 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        treePanel = new javax.swing.JPanel();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setMaximumSize(new java.awt.Dimension(2147483647, 500));
        setMinimumSize(new java.awt.Dimension(255, 52));
        setPreferredSize(new java.awt.Dimension(860, 504));
        setLayout(new java.awt.BorderLayout());

        panelLeft.setPreferredSize(new java.awt.Dimension(155, 600));

        bMakeTree.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/rebuildSmall.png"))); // NOI18N
        bMakeTree.setBorderPainted(false);
        bMakeTree.setContentAreaFilled(false);
        bMakeTree.setDefaultCapable(false);
        bMakeTree.setFocusPainted(false);
        bMakeTree.setFocusable(false);
        bMakeTree.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/res/rebuildBigPressed.png"))); // NOI18N
        bMakeTree.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/res/rebuildBig.png"))); // NOI18N
        bMakeTree.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/res/rebuildBigPressed.png"))); // NOI18N

        bCoordinator.setToolTipText("Координатор");
        bCoordinator.setBorder(null);
        bCoordinator.setBorderPainted(false);
        bCoordinator.setContentAreaFilled(false);
        bCoordinator.setFocusable(false);
        bCoordinator.setPreferredSize(new java.awt.Dimension(70, 70));
        bCoordinator.setVerifyInputWhenFocusTarget(false);
        jPanel3.add(bCoordinator);

        jLabel2.setBackground(new java.awt.Color(51, 51, 255));
        jLabel2.setForeground(new java.awt.Color(0, 51, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Координатор");
        jPanel3.add(jLabel2);

        bManager.setToolTipText("Менеджер");
        bManager.setBorder(null);
        bManager.setBorderPainted(false);
        bManager.setContentAreaFilled(false);
        bManager.setFocusable(false);
        bManager.setPreferredSize(new java.awt.Dimension(70, 70));
        bManager.setVerifyInputWhenFocusTarget(false);
        jPanel3.add(bManager);

        jLabel3.setBackground(new java.awt.Color(51, 51, 255));
        jLabel3.setForeground(new java.awt.Color(0, 51, 255));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Менеджер");
        jPanel3.add(jLabel3);

        bIngener.setToolTipText("Инженер");
        bIngener.setBorder(null);
        bIngener.setBorderPainted(false);
        bIngener.setContentAreaFilled(false);
        bIngener.setFocusable(false);
        bIngener.setPreferredSize(new java.awt.Dimension(70, 70));
        bIngener.setVerifyInputWhenFocusTarget(false);
        jPanel3.add(bIngener);

        jLabel4.setBackground(new java.awt.Color(51, 51, 255));
        jLabel4.setForeground(new java.awt.Color(0, 51, 255));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Инженер");
        jPanel3.add(jLabel4);

        bMakeTasksByTree.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/refreshSmall.png"))); // NOI18N
        bMakeTasksByTree.setToolTipText("Обновить");
        bMakeTasksByTree.setBorder(null);
        bMakeTasksByTree.setBorderPainted(false);
        bMakeTasksByTree.setContentAreaFilled(false);
        bMakeTasksByTree.setDefaultCapable(false);
        bMakeTasksByTree.setFocusable(false);
        bMakeTasksByTree.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/res/refreshBigPress.png"))); // NOI18N
        bMakeTasksByTree.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/res/refreshBig.png"))); // NOI18N
        bMakeTasksByTree.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/res/refreshBigPress.png"))); // NOI18N

        jPanel5.setLayout(new java.awt.BorderLayout());

        bOpenLPanel.setFont(new java.awt.Font("Tahoma", 1, 13));
        bOpenLPanel.setText(">");
        bOpenLPanel.setBorder(null);
        bOpenLPanel.setBorderPainted(false);
        bOpenLPanel.setContentAreaFilled(false);
        bOpenLPanel.setFocusable(false);
        bOpenLPanel.setPreferredSize(new java.awt.Dimension(15, 25));
        bOpenLPanel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bOpenLPanelActionPerformed(evt);
            }
        });
        jPanel5.add(bOpenLPanel, java.awt.BorderLayout.WEST);

        bCloseLPanel.setFont(new java.awt.Font("Tahoma", 1, 13));
        bCloseLPanel.setText("<");
        bCloseLPanel.setBorder(null);
        bCloseLPanel.setBorderPainted(false);
        bCloseLPanel.setContentAreaFilled(false);
        bCloseLPanel.setFocusPainted(false);
        bCloseLPanel.setPreferredSize(new java.awt.Dimension(15, 25));
        bCloseLPanel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
        bCloseLPanel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bCloseLPanelActionPerformed(evt);
            }
        });
        jPanel5.add(bCloseLPanel, java.awt.BorderLayout.EAST);

        javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
        panelLeft.setLayout(panelLeftLayout);
        panelLeftLayout.setHorizontalGroup(
            panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLeftLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(bMakeTree, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bMakeTasksByTree, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 120, Short.MAX_VALUE))
                .addContainerGap(13, Short.MAX_VALUE))
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
        );
        panelLeftLayout.setVerticalGroup(
            panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLeftLayout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(2, 2, 2)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bMakeTasksByTree, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bMakeTree, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(492, Short.MAX_VALUE))
        );

        add(panelLeft, java.awt.BorderLayout.WEST);

        jSplitPane1.setDividerSize(3);

        jScrollPane4.setMinimumSize(new java.awt.Dimension(250, 1000));
        jScrollPane4.setPreferredSize(new java.awt.Dimension(250, 1002));

        pRight.setPreferredSize(new java.awt.Dimension(250, 500));
        pRight.setLayout(new javax.swing.BoxLayout(pRight, javax.swing.BoxLayout.Y_AXIS));

        jPanel11.setMaximumSize(new java.awt.Dimension(32767, 80));
        jPanel11.setPreferredSize(new java.awt.Dimension(297, 100));

        jLabel6.setForeground(new java.awt.Color(102, 102, 102));
        jLabel6.setText("     Наименование:");

        jLabel10.setForeground(new java.awt.Color(102, 102, 102));
        jLabel10.setText("     Нагрузка:");

        bFixTask.setText("Закрепить");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lTime, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(120, 120, 120))
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(lName, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addContainerGap())
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bFixTask)
                .addContainerGap(200, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bFixTask)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lName, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(lTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pRight.add(jPanel11);

        jPanel7.setMaximumSize(new java.awt.Dimension(32767, 24));
        jPanel7.setPreferredSize(new java.awt.Dimension(65, 24));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel1.setText("     Свойства элемента");
        jPanel7.add(jLabel1);

        pRight.add(jPanel7);

        jScrollPane2.setPreferredSize(new java.awt.Dimension(200, 150));

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Специализация", "Квалификация"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setGridColor(new java.awt.Color(240, 240, 240));
        jTable2.setMinimumSize(new java.awt.Dimension(30, 150));
        jTable2.setPreferredSize(null);
        jTable2.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);

        pRight.add(jScrollPane2);

        jPanel8.setLayout(new javax.swing.BoxLayout(jPanel8, javax.swing.BoxLayout.Y_AXIS));

        jPanel6.setPreferredSize(new java.awt.Dimension(263, 150));

        jPanel10.setPreferredSize(new java.awt.Dimension(263, 24));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLabel11.setText("     Управленческие задачи");
        jPanel10.add(jLabel11);

        jScrollPane3.setPreferredSize(new java.awt.Dimension(150, 150));

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Task", "№ исполнителя", "Исполнитель", "Время"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable3.setGridColor(new java.awt.Color(240, 240, 240));
        jTable3.setMinimumSize(new java.awt.Dimension(30, 150));
        jTable3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable3.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(jTable3);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
            .addComponent(jPanel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))
        );

        jPanel8.add(jPanel6);

        jPanel9.setPreferredSize(new java.awt.Dimension(263, 150));

        jScrollPane1.setPreferredSize(new java.awt.Dimension(452, 150));

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Task", "№ задачи", "Задача", "Время"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setGridColor(new java.awt.Color(240, 240, 240));
        jTable1.setMinimumSize(new java.awt.Dimension(30, 150));
        jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable1.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jTable1);

        jPanel1.setPreferredSize(new java.awt.Dimension(263, 24));

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLabel9.setText("     Исполнительные задачи");
        jPanel1.add(jLabel9);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))
        );

        jPanel8.add(jPanel9);

        pRight.add(jPanel8);

        jScrollPane4.setViewportView(pRight);

        jSplitPane1.setRightComponent(jScrollPane4);

        treePanel.setBackground(new java.awt.Color(0, 153, 102));
        treePanel.setPreferredSize(new java.awt.Dimension(500, 600));
        treePanel.setLayout(new javax.swing.BoxLayout(treePanel, javax.swing.BoxLayout.LINE_AXIS));
        jSplitPane1.setLeftComponent(treePanel);

        add(jSplitPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void bCloseLPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCloseLPanelActionPerformed
        new SwingWorker() {

            @Override
            protected Object doInBackground() {
                int w = pRight.getWidth();
                for (int i = 155; i >= 15; i--) {
                    try {
                        panelLeft.setPreferredSize(new Dimension(i, (int) panelLeft.getPreferredSize().getHeight()));
//                        pRoght.setPreferredSize(new Dimension(w, 100));
                        revalidate();
                        repaint();
                        Thread.sleep(2);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(TreePanel.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                return null;
            }

            public void done() {
                bOpenLPanel.setVisible(true);
            }
        }.execute();

    }//GEN-LAST:event_bCloseLPanelActionPerformed

    private void bOpenLPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bOpenLPanelActionPerformed
        bOpenLPanel.setVisible(false);
        new SwingWorker() {

            @Override
            protected Object doInBackground() {
                for (int i = 0; i < 155; i++) {
                    try {
                        panelLeft.setPreferredSize(new Dimension(i, (int) panelLeft.getPreferredSize().getHeight()));
                        revalidate();
                        repaint();
                        Thread.sleep(2);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(TreePanel.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                return null;
            }

            public void done() {
                bCloseLPanel.setVisible(true);
            }
        }.execute();


    }//GEN-LAST:event_bOpenLPanelActionPerformed

    public void setName(String n) {
        lName.setText("  " + n);
    }

    public void setSpecQualify(ArrayList<SpecQualify> sqs) {
        if (sqs == null) {
            ((DefaultTableModel) jTable2.getModel()).setRowCount(0);
        } else {
            ((DefaultTableModel) jTable2.getModel()).setRowCount(sqs.size());
            int row = 0;
            for (SpecQualify sq : sqs) {
                jTable2.setValueAt(sq.getSpeciality().getNameOfSpeciality(), row, 0);
                jTable2.setValueAt(sq.getNameOfQualify(), row, 1);
                row++;
            }
        }
    }

    public void setTime(String t) {
        lTime.setText("  " + t);
    }

    public void setManagerTask(ArrayList<ManageTask> tasks) {
        if (tasks == null || tasks.size() == 0) {
            jPanel6.setVisible(false);
            ((DefaultTableModel) jTable3.getModel()).setRowCount(0);
        } else {
            jPanel6.setVisible(true);
            ((DefaultTableModel) jTable3.getModel()).setRowCount(tasks.size());
            int row = 0;
            for (ManageTask task : tasks) {
                jTable3.setValueAt(task, row, 0);
                jTable3.setValueAt(task.getManagedExecutor().getNumberOfExecutor(), row, 1);
                jTable3.setValueAt(task.getManagedExecutor().getNameOfExecutor(), row, 2);
                jTable3.setValueAt(Helper.getMinutesToString(task.getTimeInMinutes()), row, 3);
                row++;
            }
        }
    }

    private Executor executor = null;

    public void setTask(ArrayList<Task> tasks, Executor executor) {
        if (tasks == null) {
            executor = null;
            ((DefaultTableModel) jTable1.getModel()).setRowCount(0);
        } else {
            this.executor = executor;
            ((DefaultTableModel) jTable1.getModel()).setRowCount(tasks.size());
            int row = 0;
            for (Task task : tasks) {
                jTable1.setValueAt(task, row, 0);
                jTable1.setValueAt(task.getNumberOfTask(), row, 1);
                jTable1.setValueAt(task.getNameOfTask(), row, 2);
                jTable1.setValueAt(Helper.getMinutesToString(task.getTimeInMinutes()), row, 3);
                row++;
            }
        }
    }

    private void makeButton() {
        Options opt = Options.get();
        int width = 70, height = 70;
        bCoordinator.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        bManager.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        bIngener.setCursor(new Cursor(Cursor.MOVE_CURSOR));
//        bCoordinator.setIcon(createIconForButton(opt.getColorOfCoordinator(), width, height));
//        bManager.setIcon(createIconForButton(opt.getColorOfManager(), width, height));
//        bIngener.setIcon(createIconForButton(opt.getColorOfIngener(), width, height));
        try {
            bCoordinator.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(ImageIO.read(this.getClass().getResource("/model/tree/image/c.jpg")).getSource(), new ReplicateScaleFilter(width, height)))));
            bManager.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(ImageIO.read(this.getClass().getResource("/model/tree/image/m.jpg")).getSource(), new ReplicateScaleFilter(width, height)))));
            bIngener.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(ImageIO.read(this.getClass().getResource("/model/tree/image/e.jpg")).getSource(), new ReplicateScaleFilter(width, height)))));

        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    private Icon createIconForButton(Color color, int width, int height) {
        BufferedImage bi = new BufferedImage(70, 70, BufferedImage.TYPE_INT_ARGB);
        Shape shape = new Ellipse2D.Double(0, 0, bi.getWidth(), bi.getHeight());
        Graphics2D g2 = (Graphics2D) bi.getGraphics();
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        RoundGradientPaint rgp = new RoundGradientPaint(shape.getBounds().getX(), shape.getBounds().getY(), Color.WHITE,
                new Point2D.Double(shape.getBounds().getBounds().getWidth() / 2 + 10, shape.getBounds().getBounds().getHeight() / 2), color);
        g2.setPaint(rgp);
        g2.fill(shape);
        return new ImageIcon(bi);
    }

    class TaskRenderer extends DefaultTableCellRenderer {
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value,
                                                       boolean isSelected,
                                                       boolean hasFocus,
                                                       int row,
                                                       int column) {

            setText(value.toString());

            //System.out.println(table.getValueAt(row, 5));
            if (ManagerInitTree.getInstance().getInitParam() == ManagerInitTree.ANALYS_INIT && !isSelected && !AnalysManager.isMakeTaskExecutor(executor, ((Task) table.getValueAt(row, 0)))) {
                setBackground(Color.BLUE);
                setForeground(Color.BLACK);
            } else if (ManagerInitTree.getInstance().getInitParam() == ManagerInitTree.PROGRESS_INIT && !isSelected && ((Task) table.getValueAt(row, 0)).isNew()) {
                setBackground(Color.GREEN);
                setForeground(Color.BLACK);
            } else {
                if (isSelected) {
                    setBackground(table.getSelectionBackground());
                    setForeground(table.getSelectionForeground());
                } else {
                    setBackground(table.getBackground());
                    setForeground(table.getForeground());
                }
            }

            return this;
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton bCloseLPanel;
    public javax.swing.JButton bCoordinator;
    public javax.swing.JButton bFixTask;
    public javax.swing.JButton bIngener;
    public javax.swing.JButton bMakeTasksByTree;
    public javax.swing.JButton bMakeTree;
    public javax.swing.JButton bManager;
    public javax.swing.JButton bOpenLPanel;
    private javax.swing.ButtonGroup buttonGroup;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    public javax.swing.JSplitPane jSplitPane1;
    public javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JLabel lName;
    private javax.swing.JLabel lTime;
    public javax.swing.JPanel pRight;
    public javax.swing.JPanel panelLeft;
    private javax.swing.JPanel treePanel;
    // End of variables declaration//GEN-END:variables
}

